package com.chaihu.admin.service.impl.menugroup;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chaihu.admin.dao.MenuGroupServiceDao;
import com.chaihu.bean.dto.admin.MenuGroupDto;
import com.chaihu.bean.in.admin.menugroup.SaveMenuGroupIn;
import com.chaihu.bean.result.ResponseResult;
import com.chaihu.core.factory.GenerateCodeFactory;
import com.chaihu.intf.admin.menugroup.SaveMenuGroupService;
import com.chaihu.intf.icommon.BaseService;
import com.chaihu.utils.util.BeanConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
public class SaveMenuGroupServiceImpl extends BaseService<ResponseResult<Void>, SaveMenuGroupIn> implements SaveMenuGroupService {
    @Autowired
    private MenuGroupServiceDao menuGroupServiceDao;

    @Override
    public ResponseResult<Void> checkHandle(ResponseResult<Void> responseResult, SaveMenuGroupIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> doHandle(ResponseResult<Void> responseResult, SaveMenuGroupIn in) {
        if(StringUtils.isEmpty(in.getgId())){
            in.setgId(GenerateCodeFactory.getGeneratorId(GenerateCodeFactory.MENU_GROUP));
        }
        int i = menuGroupServiceDao.insert(in);
        return responseResult;
    }

    @Override
    public ResponseResult<Void> respHandle(ResponseResult<Void> responseResult, SaveMenuGroupIn in) {
        return responseResult;
    }

    @Override
    public ResponseResult<Void> saveMenuGroup(SaveMenuGroupIn in) {
        ResponseResult<Void> result = new ResponseResult<>();
        return this.mainHandle(result, in);
    }
}
